<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="common/include :: header('请求审核列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label>创建时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
                        </li>
                        <li>
                            状态：<select name="status" th:with="type=${@dict.getType('cpa_status')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
                        </select>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary" id="startAudit" onclick="startAudit()" shiro:hasPermission="system:post:edit">
                <i class="fa fa-edit"></i> 发起申请
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="common/include :: footer" />
</body>

<script th:inline="javascript">
    var statusDatas = [[${@dict.getType('cpa_status')}]];
    var editFlag = [[${@permission.hasPermi('business:leave:edit')}]];
    var removeFlag = [[${@permission.hasPermi('business:leave:remove')}]];
    var prefix = ctx + "/business/leave";

    $(function() {
        var options = {
            url: prefix + "/query",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "请假审核",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    visible: false
                },
                {
                    field: 'name',
                    title: '用户名称'
                },

                {
                    field: 'reason',
                    title: '请假原因',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value, 10);
                    }
                },
                {
                    field: 'startTime',
                    title: '开始时间'
                },
                {
                    field: 'endTime',
                    title: '结束时间'
                },
                {
                    field: 'auditor.userName',
                    title: '审核人名称'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                }]
        };
        $.table.init(options);
    });

    // 点击发起申请后执行的函数
    function startAudit() {
        $.modal.open("发起申请页面", "/business/leave/startAuditPage");
    }

</script>
</html>